<?php

namespace App\Http\Requests\client;

use App\Http\ValidateResult;
use Illuminate\Support\Facades\Validator;

trait PriceRequest
{
    public static function add_check(array $params): ValidateResult {
        $validator = Validator::make($params, [
            'customer_id' => 'required',
            'currency_id' => 'required',
            'effect_date' => 'required',
            'detail' => 'required',
        ], [
            'customer_id.required' => '请选择客户',
            'currency_id.required' => '请选择币种',
            'effect_date.required' => '请选择生效日期',
            'detail.required' => '请填写价格详情',
        ]);

        if ($validator->fails()) {
            return ValidateResult::error($validator->errors()->first());
        }
        return ValidateResult::correct();
    }

}
